
// export default function access(initialState: { currentUser?: API.CurrentUser } | undefined) {
//   const { currentUser } = initialState ?? {};
//   return {
//     canAdmin: currentUser && currentUser.access === 'admin',
//   };
// }

// 路由权限------权限信息配置
// import { useModel }  from 'umi';

export default function access(initialState: { currentUser?: API.CurrentUser } | undefined) {
  
  const { currentUser } = initialState ?? {};

  // 用于权限检查 判断是否已经写入权限，未登录时，未定义
  if (currentUser && currentUser.permissionslist) {
    const permissionslist = currentUser.permissionslist
    return { 
      canAdmin:  permissionslist.includes('submit_activity'),
      canFiles: permissionslist.includes('view_document'), // 文件页面权限查看
      canActivity:  permissionslist.includes('view_activityapplication'), // 活动页面权限查看
      canSample: (permissionslist.includes('view_inputtable') || permissionslist.includes('view_outputtable')), // 样衣页面查看
      canInput: permissionslist.includes('view_inputtable'), // 入库页面查看
      canOutput: permissionslist.includes('view_outputtable'),  // 出库页面查看
     }
  };
  return {
    
  }
  // return { canAdmin: currentUser && currentUser.access === 'admin', }
}
